package com.lbd.system.bean;

import com.lbd.base.bean.AbstractEntity;
import lombok.*;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import java.util.List;

/**
 * 这个是项目中的数据字典
 * 针对的是后台管理的下拉框,
 * 和前台状态字段的取值
 */
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@DynamicUpdate
@Entity
public class Dictionary extends AbstractEntity {


    /**
     * 字典
     */
    String name;
    /**
     * 编码
     */
    //@Column(unique = true)
    String code;
    /**
     * p排序字段
     */
    int orderBy;
    /**
     * 父id
     */
//    String parentId;
//
    @ManyToOne
    @JoinColumn(name = "parent_Id")
    Dictionary parent;
    @OneToMany
    @JoinColumn(name = "parent_Id")
    private List<Dictionary> items;
}
